%global sname pymod2pkg
{% set pypi_name = 'pymod2pkg' %}
{% set upstream_version = upstream_version('0.26.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Packaging - python module name to package name map
License:        {{ license('Apache-2.0') }}
Group:          Development/Libraries/Python
URL:            https://wiki.openstack.org/wiki/Rpm-packaging
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('distro') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testresources') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
pymod2pkg is a simple python module for translating python module names to
corresponding package names which is a common problem in the packaging world.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Packaging - python module name to package name map
Requires:       {{ py3('distro') }}
Requires:       {{ py3('pbr') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 0.23.0
%endif

%description -n {{ py2name(py_versions='py3') }}
pymod2pkg is a simple python module for translating python module names to
corresponding package names which is a common problem in the packaging world.

This package contains the Python 3.x module.

%package -n {{ py2name() }}-doc
Summary:        Documentation for python module name to package name map library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name() }}-doc
Documentation for python module name to package name map library.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
%sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README*
%{_bindir}/pymod2pkg
%{python3_sitelib}/*

%files -n {{ py2name() }}-doc
%doc doc/build/html
%license LICENSE

%changelog
